package org.goj.user.controller;


import org.goj.common.entity.user.Resource;
import org.goj.common.model.Result;
import org.goj.user.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author CK
 * @since 2020-12-16
 */
@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    @PostConstruct
    @GetMapping(value = "/initResourceRolesMap")
    Boolean initResourceRolesMap() {
        return resourceService.initResourceRolesMap();
    }

    /**
     * 查询接口列表
     *
     * @return Result<Map < String, Object>>
     * @author CK
     * @date 2021/5/9 20:05
     */
    @GetMapping("/listResource")
    public Result<List<Map<String, Object>>> listResource() {
        List<Map<String, Object>> map = resourceService.listResource();
        return Result.succeed("查询接口列表成功", map);
    }

}

